package com.itboye.mengwu.data.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.IGoodsDetail;
import com.itboye.mengwu.data.model.GoodsDetailBean;
import com.itboye.mengwu.data.repository.GoodsDetailRepository;

public class GoodsDetailPresenter extends BasePresenter implements
		IGoodsDetail<GoodsDetailBean> {
	public static final String GoodsDetail_Query_SUCCESS = MainPresenter.class
			.getName() + "_GoodsDetail_Query_success";
	public static final String GoodsDetail_Query_FAILE = MainPresenter.class
			.getName() + "_GoodsDetail_Query_failure";
	
	public static final String StorePromotion_SUCCESS = MainPresenter.class
			.getName() + "_StorePromotion_success";
	public static final String StorePromotion_FAILE = MainPresenter.class
			.getName() + "_StorePromotion_failure";
	
	//商品咨询保存
	public static final String AskGoodsSave_SUCCESS = MainPresenter.class
			.getName() + "_AskGoodsSave_success";
	public static final String AskGoodsSave_FAILE = MainPresenter.class
			.getName() + "_AskGoodsSave_failure";
	
	//.商品咨询查询
	public static final String AskGoodsQuery_SUCCESS = MainPresenter.class
			.getName() + "_AskGoodsQuery_success";
	public static final String AskGoodsQuery_FAILE = MainPresenter.class
			.getName() + "_AskGoodsQuery_failure";

	//商品评价BY_Product_comment
	public static final String Product_comment_SUCCESS = MainPresenter.class
			.getName() + "_Product_comment_success";
	public static final String Product_comment_FAILE = MainPresenter.class
			.getName() + "_Product_comment_failure";
	public GoodsDetailPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(GoodsDetailBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(GoodsDetailBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(GoodsDetailBean model) {
		// TODO Auto-generated method stub

	}

	/**
	 * 查询商品评价
	 */
	@Override
	public void getInfo(GoodsDetailBean model) {
		// TODO Auto-generated method stub
		IGoodsDetail<GoodsDetailBean> goodsDetail = new GoodsDetailRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Product_comment_SUCCESS);
						GoodsDetailPresenter.this.setChanged();
						GoodsDetailPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(Product_comment_FAILE);
						GoodsDetailPresenter.this.setChanged();
						GoodsDetailPresenter.this.notifyObservers(result);
					}
				});
		goodsDetail.getInfo(model);
	}

	@Override
	public List<GoodsDetailBean> queryYouHuiQuan(GoodsDetailBean model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void queryGoods(String pid, String uid) {
		// TODO Auto-generated method stub
		IGoodsDetail<GoodsDetailBean> goodsDetail = new GoodsDetailRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(GoodsDetail_Query_SUCCESS);
						GoodsDetailPresenter.this.setChanged();
						GoodsDetailPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(GoodsDetail_Query_FAILE);
						GoodsDetailPresenter.this.setChanged();
						GoodsDetailPresenter.this.notifyObservers(result);
					}
				});
		goodsDetail.queryGoods(pid, uid);
	}

	@Override
	public void StorePromotion(String store_id) {
		// TODO Auto-generated method stub
		IGoodsDetail<GoodsDetailBean> goodsDetail = new GoodsDetailRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(StorePromotion_SUCCESS);
						GoodsDetailPresenter.this.setChanged();
						GoodsDetailPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(StorePromotion_FAILE);
						GoodsDetailPresenter.this.setChanged();
						GoodsDetailPresenter.this.notifyObservers(result);
					}
				});
		goodsDetail.StorePromotion(store_id);
	}

	@Override
	public void AskGoodsSave(String pid, String ask_content, String ask_uid,
			String ask_username) {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
				IGoodsDetail<GoodsDetailBean> goodsDetail = new GoodsDetailRepository(
						new ICompleteListener() {

							@Override
							public void success(ResultEntity result) {
								// TODO Auto-generated method stub
								result.setEventTag(Tag_Success);
								result.setEventType(AskGoodsSave_SUCCESS);
								GoodsDetailPresenter.this.setChanged();
								GoodsDetailPresenter.this.notifyObservers(result);
							}

							@Override
							public void failure(ResultEntity result) {
								// TODO Auto-generated method stub
								result.setEventTag(Tag_Error);
								result.setEventType(AskGoodsSave_FAILE);
								GoodsDetailPresenter.this.setChanged();
								GoodsDetailPresenter.this.notifyObservers(result);
							}
						});
				goodsDetail.AskGoodsSave(pid, ask_content, ask_uid, ask_username);
	}

	@Override
	public void GoodsQuery(String pid, String page_no, String page_size) {
		// TODO Auto-generated method stub
		IGoodsDetail<GoodsDetailBean> goodsDetail = new GoodsDetailRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(AskGoodsQuery_SUCCESS);
						GoodsDetailPresenter.this.setChanged();
						GoodsDetailPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(AskGoodsQuery_FAILE);
						GoodsDetailPresenter.this.setChanged();
						GoodsDetailPresenter.this.notifyObservers(result);
					}
				});
		goodsDetail.GoodsQuery(pid, page_no, page_size);//
	}

}
